#include <iostream>
using namespace std;
struct node{
	int x;int y;
};
int main() {
	struct node que[2501];
	int head=1;int tail=1;
	int a[51][51];
	int book[51][51]={0};
	int tx,ty,i,j,m,n,k,x,y;
	int next[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
	cin>>m>>n>>x>>y;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
		cin>>a[i][j];
	book[x][y]=1;
	que[tail].x=x;
	que[tail].y=y;
	tail++;
	int sum=1;
	while(head<tail){
		for(k=0;k<=3;k++){
		tx=que[head].x+next[k][0];
		ty=que[head].y+next[k][1];
		if(tx<1||tx>n||ty<1||ty>m) continue;
		if(book[tx][ty]==0 &&a[tx][ty]!=0){
			sum++;
			book[tx][ty]=1;
			que[tail].x=tx;
			que[tail].y=ty;
			tail++;
		}
	}
	head++;
	}
    cout<<sum<<endl;
    return 0;
}

